package com.yh.dp.principle.ocp;

import java.lang.reflect.Constructor;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @ClassName BookStore
 * @Description 书店
 * @Author 0715-YuHao
 * @Date 2021/1/2 14:56
 */
public class BookStore {

    //图书集合
    private static ArrayList<IBook> bookList = new ArrayList<>();

    static {
        bookList.add(new OffNovelBook("红楼梦", 9900, "曹雪芹 "));
        bookList.add(new OffNovelBook("侠客行", 8900, "金庸 "));
        bookList.add(new OffNovelBook("原则", 6900, "瑞·达利欧"));
        bookList.add(new OffNovelBook("海贼王1", 4900, "尾田荣一郎"));
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            scanner.nextLine();
            NumberFormat format = NumberFormat.getCurrencyInstance();
            format.setMaximumFractionDigits(2);
            System.out.println("-----------------书店卖书记录如下----------------------");
            for (IBook book : bookList) {
                System.out.println("书籍名称：" + book.getName() +
                        "\t\t作者：" + book.getAuthor() +
                        "\t\t价 格：" + format.format(book.getPrice() / 100.0) + " 元");
            }
        }
    }
}
